<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户信息列表')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
    <div class="ui-layout-west">
        <div class="box box-main">
            <div class="box-header">
                <div class="box-title">
                    <i class="fa icon-grid"></i> 组织机构
                </div>
                <div class="box-tools pull-right">
                    <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
                    <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
                    <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新"><i class="fa fa-refresh"></i></button>
                </div>
            </div>
            <div class="ui-layout-content">
                <div id="tree" class="ztree"></div>
            </div>
        </div>
    </div>
    <div class="ui-layout-center">
         <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form id="formId">
                        <input type="hidden" id="deptId" name="deptId">
                        <input type="hidden" id="parentId" name="parentId">
                        <div class="select-list">
                            <ul>

                                <li>
                                    姓名：
                                    <input type="text" name="userName"/>
                                </li>

                                <li>
                                    <label>年龄：</label>
                                    <input type="text"  id="startAge" placeholder="初始年龄" name="params[beginAge]"/>
                                    <span>至</span>
                                    <input type="text"  id="endAge" placeholder="结束年龄" name="params[endAge]"/>
                                </li>

                                <li class="select-time">
                                    <label>出生年月：</label>
                                    <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                                    <span>-</span>
                                    <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                                </li>
                                <li class="select-time">
                                    <label>工作时间：</label>
                                    <input type="text" class="time-input" id="beginWorkTime" placeholder="开始时间" name="params[beginWorkTime]"/>
                                    <span>-</span>
                                    <input type="text" class="time-input" id="endWorkTime" placeholder="结束时间" name="params[endWorkTime]"/>
                                </li>
                                <li class="select-time">
                                    <label>入党时间：</label>
                                    <input type="text" class="time-input" id="beginPartyTime" placeholder="开始时间" name="params[beginPartyTime]"/>
                                    <span>-</span>
                                    <input type="text" class="time-input" id="endPartyTime" placeholder="结束时间" name="params[endPartyTime]"/>
                                </li>
                                <li class="select-time">
                                    <label>退休时间：</label>
                                    <input type="text" class="time-input" id="beginRetireTime" placeholder="开始时间" name="params[beginRetireTime]"/>
                                    <span>-</span>
                                    <input type="text" class="time-input" id="endRetireTime" placeholder="结束时间" name="params[endRetireTime]"/>
                                </li>
                                <li>
                                    籍贯：
                                    <input type="text" name="nativePlace"/>
                                </li>
                                <li>
                                    身份：
                                    <select name="identity" th:with="type=${@dict.getType('old_identity')}">
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </li>
                                <li>
                                    性别：
                                    <select name="sex" th:with="type=${@dict.getType('sys_user_sex')}">
                                        <option value="">所有</option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </li>
                                <li>
                                    <label>政治面貌：</label>
                                    <input type="text" name="politics"/>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>

                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="cadre:cadre:add">
                        <i class="fa fa-plus"></i> 添加
                    </a>
                    <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="cadre:cadre:edit">
                        <i class="fa fa-edit"></i> 修改
                    </a>
                    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="cadre:cadre:remove">
                        <i class="fa fa-remove"></i> 删除
                    </a>
                    <a class="btn btn-warning" onclick="test()" shiro:hasPermission="cadre:cadre:export">
                        <i class="fa fa-download"></i> 导出
                    </a>
                </div>
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: layout-latest-js" />
    <th:block th:include="include :: ztree-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('cadre:cadre:edit')}]];
        var removeFlag = [[${@permission.hasPermi('cadre:cadre:remove')}]];
        var organizationType = [[${@dict.getType('old_organization_type')}]];
        var professionalLevel = [[${@dict.getType('old_professional_level')}]];
        var maritalStatus = [[${@dict.getType('old_marital_status')}]];
        var housePurchase = [[${@dict.getType('old_house_purchase')}]];
        var identity = [[${@dict.getType('old_identity')}]];
        var sex = [[${@dict.getType('sys_user_sex')}]];
         var prefix = ctx + "cadre/cadre";

        $(function() {
            var panehHidden = false;
            if ($(this).width() < 769) {
                panehHidden = true;
            }
            $('body').layout({ initClosed: panehHidden, west__size: 185 });
            queryUserList();
            queryDeptTree();
        });

        function test(formId){ //<-- $.table.exportExcel()-->
            table.set();
            var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);

            $.modal.confirm("确认要导出数据吗?", function() {
                var url = table.options.removeUrl;
                var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
                var data = { "ids": rows.join() ,"sysUserCadre":$("#" + currentId).serializeArray()};
                //$.operate.submit("/system/student/export", "post", "json", data);
                $.modal.loading("正在导出数据，请稍后...");
                $.post("/cadre/cadre/export", data, function(result) {
                    if (result.code == web_status.SUCCESS) {
                        window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    } else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                });

            });
        }

        function queryDeptTree()
        {
            var url = ctx + "system/dept/treeData";
            var options = {
                url: url,
                expandLevel: 2,
                onClick : zOnClick
            };
            $.tree.init(options);

            function zOnClick(event, treeId, treeNode) {
                $("#deptId").val(treeNode.id);
                $("#parentId").val(treeNode.pId);
                $.table.search();
            }
        }

        $('#btnRefresh').click(function() {
            queryDeptTree();
        });


        function queryUserList() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "用户信息",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'userId',
                        title: '用户ID',
                        visible: false
                    },
                    {
                        field: 'userName',
                        title: '姓名'
                    },
                    {
                        field: 'birthday',
                        title: '出生年月',
                        sortable: true
                    },
                    {
                        field: 'age',
                        title: '年龄',
                        sortable: true
                    },
                    {
                        field: 'nativePlace',
                        title: '籍贯'
                    },
                    {
                        field: 'identity',
                        title: '身份',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(identity, value);
                        }
                    },
                    {
                        field: 'phonenumber',
                        title: '本人联系电话'
                    },
                    {
                        field: 'sex',
                        title: '性别',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(sex, value);
                        }
                    },
                    {
                        field: 'education',
                        title: '学历'
                    },
                    {
                        field: 'nation',
                        title: '民族'
                    },
                    {
                        field: 'organizationType',
                        title: '编制类型',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(organizationType, value);
                        }
                    },
                    {
                        field: 'politics',
                        title: '政治面貌'
                    },
                    {
                        field: 'partyTime',
                        title: '入党时间',
                        sortable: true
                    },
                    {
                        field: 'workTime',
                        title: '工作时间',
                        sortable: true
                    },
                    {
                        field: 'retireTime',
                        title: '退休时间',
                        sortable: true
                    },
                    {
                        field: 'retireCompany',
                        title: '退休时所在单位'
                    },
                    {
                        field: 'retireJob',
                        title: '退休时职务'
                    },
                    {
                        field: 'retireLevelPublic',
                        title: '退休时职级(参公编制)'
                    },
                    {
                        field: 'retireLevelCause',
                        title: '退休时职级(事业编制)'
                    },
                    {
                        field: 'professionalSkill',
                        title: '专业技术职务'
                    },
                    {
                        field: 'professionalLevel',
                        title: '专业职务级别',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(professionalLevel, value);
                        }
                    },
                    {
                        field: 'incomeAll',
                        title: '月收入总额(元)'
                    },
                    {
                        field: 'incomeRetire',
                        title: '基本退休费'
                    },
                    {
                        field: 'subsidyLife',
                        title: '生活补贴'
                    },

                    {
                        field: 'maritalStatus',
                        title: '婚姻状况',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(maritalStatus, value);
                        }
                    },
                    {
                        field: 'spouseName',
                        title: '配偶姓名'
                    },

                    {
                        field: 'spousePhone',
                        title: '配偶联系电话'
                    },
                    {
                        field: 'housePurchase',
                        title: '购房情况',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(housePurchase, value);
                        }
                    },


                    {
                        title: '操作',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.userId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>删除</a>');
                            return actions.join('');
                        }
                    }]
            };
            $.table.init(options);
        }
    </script>
</body>
</html>